﻿/// -----------------------------------------------------------------------
/// (c) 2009 Microsoft Corporation -- All rights reserved
/// This code is licensed under the MS-PL
/// http://www.opensource.org/licenses/ms-pl.html
/// Courtesy of the Open Source Techology Center: http://port25.technet.com
/// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.XPath;
using System.Xml;
using System.Text.RegularExpressions;

namespace mkProject {

    public class TargetCommandLine : CommandLine {
        public List<string> objectFiles = new List<string>();
        public List<string> libFiles = new List<string>();
        public List<string> libPaths = new List<string>();
        public List<string> SourceFiles = new List<string>();
        public List<string> resourceFiles = new List<string>();
        public string defFile = "";

        public string OutputFilename;
        public string OutputRelativeDirectory;
        public string UniqueName;
        public string OutputExtension;
        public TargetCommandLine(string commandLine)
            : base(commandLine) {

            Regex regEx = new Regex(@"\b(\S*?\.obj)\b", RegexOptions.IgnoreCase);
            MatchCollection matches = regEx.Matches(commandLine);
            foreach (Match file in matches) {
                objectFiles.Add(MakeProject.App.Redirect(UnMuckString(file.Captures[0].Value.Trim())));
            }


            regEx = new Regex(@"[/-]def:(\S*)", RegexOptions.IgnoreCase);
            foreach (string cmdSwitch in switches) {
                matches = regEx.Matches(cmdSwitch);
                foreach (Match path in matches) {
                    defFile = MakeProject.App.Redirect(UnMuckString(path.Groups[1].Value.Trim()));
                }
            }
        }
    }
}
